package de.unidue.langtech.teaching.pp.example;

import java.util.Collection;

import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
import org.apache.uima.fit.util.JCasUtil;
import org.apache.uima.jcas.JCas;

import de.unidue.langtech.teaching.pp.type.BaseTime;
import de.unidue.langtech.teaching.pp.type.TimexEvent;

/**
 * The baseline prints out the number of timex events for every file. It alway takes the basetime of the document as the detectedValue. For better reults the RuleBasedSolver is used.
 */
public class Baseline extends JCasAnnotator_ImplBase {
	
	@Override
	public void process(JCas jcas) throws AnalysisEngineProcessException {

		Collection<TimexEvent> timexEvents = JCasUtil.select(jcas,TimexEvent.class);
		BaseTime basetime = JCasUtil.selectSingle(jcas, BaseTime.class);

		for (TimexEvent timexEvent : timexEvents) {
			timexEvent.setDetectedValue(basetime.getValue());
			if (timexEvents.size() > 1) {
				System.out.println("File contains " + timexEvents.size() + " timex events:");
			} else if (timexEvents.size() < 1) {
				System.out.println("File contains no timex events.");
			} else {
				System.out.println("File contains " + timexEvents.size() + " timex event:");
			}
	}
}
}